Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hapi/hoek

Package Overview
Dependencies
Maintainers
6
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hapi/hoek

General purpose node utilities

  • 9.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13M
decreased by-14.66%
Maintainers
6
Weekly downloads
 
Created

What is @hapi/hoek?

The @hapi/hoek package is a utility module for the hapi ecosystem, providing a set of common function helpers that are used across multiple hapi modules. It includes functions for manipulating objects, arrays, and other types, as well as utility functions for assertions, cloning, merging, and more.

What are @hapi/hoek's main functionalities?

Object Cloning

Creates a deep clone of an object, ensuring that nested objects are also cloned rather than just copying their references.

const Hoek = require('@hapi/hoek');
const obj = { a: 1, b: { c: 2 } };
const clone = Hoek.clone(obj);

Object Merging

Merges all the properties of the source object into the target object. This is a deep merge operation.

const Hoek = require('@hapi/hoek');
const target = { a: 1 };
const source = { b: 2 };
Hoek.merge(target, source);

Assertion

Throws an error if the condition is not true. Useful for adding assertions in your code to ensure that certain conditions are met.

const Hoek = require('@hapi/hoek');
Hoek.assert(1 === 1, 'This will not throw.');
Hoek.assert(1 === 2, 'This will throw an error.');

Reach

Allows you to access a nested property within an object using a string path.

const Hoek = require('@hapi/hoek');
const obj = { a: { b: { c: 1 } } };
const value = Hoek.reach(obj, 'a.b.c');

Apply To Defaults

Applies a set of default keys and values to an object, only adding values if they are not already present in the object.

const Hoek = require('@hapi/hoek');
const defaults = { a: 1, b: 2 };
const options = { b: 3, c: 4 };
const result = Hoek.applyToDefaults(defaults, options);

Other packages similar to @hapi/hoek

Keywords

FAQs

Package last updated on 01 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc